home *** CD-ROM | disk | FTP | other *** search
- *****Listing 3*****
-
- class Register {
- public:
- // move point forward one character
- virtual void go( Buffer &b, File &output)
- {
- if( b.isend() )
- output.put( "?\n" );
- else
- b.next();
- }
-
- // print character after point and move point forward
- virtual void print( Buffer &b, File &output)
- {
- if( b.isend() )
- output.put( "?\n" );
- else
- output.put( b.geta());
- go(); // Register::go()
- }
-
- // insert after point
- virtual void insert( Buffer &b, File &input)
- {
- int c;
- int prev = '\n';
- while( !input.iseof() ) {
- c = input.get();
- if( (prev == '\n') && (c == '.') )
- if( input.peek() == '\n' ) {
- input.get();
- break;
- }
- b.putb( c);
- prev = c;
- }
- }
-
- virtual void del( Buffer &b, Buffer &kbuf, File &output)
- {
- if( b.isend() )
- output.put( "?\n" );
- else {
- // need to capture deletion into kill buf
- // empty out the kbuf ...
- for( kbuf.begin(); !kbuf.isend(); kbuf.next())
- kbuf.dela();
- kbuf.putb( b.dela());
- }
- }
-
- virtual void put( Buffer &b, Buffer &kbuf)
- { b.putb( kbuf.geta()); }
-
- // no need for data members. defaults are implicit!
- };
-
-